import { setToken, clearToken } from '@/utils'
import { http } from '@/utils'
export const login = (data) => {
  return async (dispatch) => {
    const {
      data: {
        data: { token },
        message,
      },
    } = await http.post('/authorizations', data)
    if (message === 'OK') {
      dispatch({ type: 'login/token', payload: token })
      console.log(token)
      setToken(token)
    }
    // localStorage.setItem('geek-token', token)
  }
}
export const clearInfo = () => {
  return (dispatch) => {
    dispatch({ type: 'login/clearToken' })
    clearToken()
    dispatch({ type: 'login/clearInfo' })
  }
}
